<template>
	<view class="add-patient-content">
		<view class="add-patient-msg">
			<view class="patient-msg-row" v-for="item in patient" :key="item.id">
				<text>{{item.title}}</text>
				<u-input type="text" placeholder="请填写" v-model="params[item.id]" :clearable="false"
					style="height:90rpx;width: 100%;margin-top: 20rpx;">
				</u-input>
			</view>
		</view>
		<view class="add-btn-row">
			<u-button type="default" shape="circle" text="添加" class="add-btn" @click="addHandle" hover-class="none">添加
			</u-button>
		</view>
	</view>
</template>

<script>
	import {
		API
	} from '@/config/myApi.js';
	export default {
		data() {
			return {
				params: {
					birthday: "2022-10-14 21:21:54",
					createTime: "2022-10-14 21:21:54",
					id: "1580897592848834560",
					mobile: "18328035013",
					sex: 0,
					userId: 1578209345232531500,
					username: "张山",
					visitCardNo: "1234567890",
					//身份证号
				},
				//遍历信息
				patient: [{
					title: '姓名',
					id: 'username',
				}, {
					title: '身份证号',
					id: 'idCard',
				}, {
					title: '性别',
					id: 'sex',
				}, {
					title: '出生日期',
					id: 'birthday',
				}, {
					title: '手机号',
					id: 'mobile',
				}]
			}
		},
		methods: {
			async addHandle() {
				console.log("添加咨询人",this.params);
				if (this.params.sex==="男") {
					this.params.sex = 0
				} else{
					this.params.sex = 1
				}
				let res = await  API.bindRelationUser(this.params)
				if (res.code===200) {
				console.log("添加咨询人结果",res);
				// console.log('添加患者');
				uni.navigateBack()
				}
				// uni.navigateTo({
				// 	url:'/pages/mine/myConsultation/startConsulting'
				// })
			}
		}
	}
</script>

<style lang="scss" scoped>
	.add-patient-content {
		padding: 30rpx;

		.add-patient-msg {
			padding: 0rpx 24rpx;
			background: #fff;
			border-radius: 12rpx;

			.patient-msg-row {
				height: 109rpx;
				border-bottom: 1rpx solid #E3E3E3;
				display: flex;
				align-items: center;
				overflow: hidden;
				>text {
					display: block;
					width: 184rpx;
					font-size: 15px;
					font-weight: bold;
				}
			}

			.patient-msg-row:last-child {
				border-bottom: none;
			}
		}

		.add-btn-row {
			width: 690rpx;
			position: fixed;
			left: 30rpx;
			bottom: 32rpx;
			.add-btn {
				background-color: #F4333C;
				color: #fff;
				height: 90rpx;
			}

			.u-hairline-border:after {
				border: none;
			}
		}

	}
</style>
